var express = require('express');
var router = express.Router();
var path = require('path');
var getUserInfo = require(path.join(__dirname,'../checkLogin/getUserInfo'));
router.get('/',function(req,res,next){
    res.render('login');
})

router.post('/', function (req, res, next) {
    let username = req.body.username;
    let password = req.body.password;
    let userId = getUserInfo.checkpassword(username, password);
    if (userId === false){
        res.json({
            msg:'账号密码错误'
        })
    }else{
        res.cookie('userId', userId);
        res.redirect('/users');
    }
})

module.exports = router